/**
 *  列表 入口文件
 * */
import axios from 'axios'
import Index from './index.vue'

let sys = null

function getSys() {
    'use strict'
    return axios.get('/static/dynamic-form-config.js$null').then(res => {
        if (res.status !== 200) {
            console.warn('使用默认配置');
            return require('./page.js')
        }
        let exports = {}
        eval(res.data);
        return exports;
    })
}

export default {
    functional: true,
    beforeRouteEnter(to, from, next) {
        if (sys) return next()
        getSys().then(function (_sys) {
            sys = _sys;
            next()

            /* 清理 */
            getSys = null
        })
    },
    render(h, context) {
        return <Index sys={sys} key={context.parent.$route.fullPath}/>
    },
}
